<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //构造函数
    //Person.prototype
    //通过 Person.protype 实现属性和方法共享
    function Person(){

    }
    Person.prototype.kind="人类";
    Person.prototype.sayHello = function(){
        console.log("人类说了 sayhello")
    }
    //定义一个Man
    function Man(name){
        //相当于访问父类
        Person.call(this.name); //super(name)
        this.name = name;
    }
    //Object.create 创建一个新的对象
    //以 Person.prototype 为基础 => {kind:"人类",sayHello:function(){}}

    Man.prototype = Object.create(Person.prototype,{});
    //修正构造函数
    Man.prototype.constructor = Man;
    let xiaoming = new Man("小明");
    
    console.log(xiaoming);
    //Man {name: "小明"}

    console.log(xiaoming.sayHello());
    //人类说了 sayhello

    console.log(xiaoming.kind);
    //人类
</script>
</html>